<?php

namespace addons\news\controllers;
use addons\news\models\VoteNewsModel;
use controllers\AdminApi;

class index extends AdminApi {
    /**
     * 初始化
     */
    public function onStepUp(){
        $this->model = new VoteNewsModel();
    }

    /**
     * 分类接口
     * @param string $title
     * @return array
     */
    public function index($title = '') {
        $map = [];
        if ($title){
        	$map['title'] = ['like' , $title];
		}
        $data = $this->model->where($map)->select();
        foreach ($data as &$val){
        	$val['create_time'] = timeFormat($val['create_time']);
        	unset($val['name']);
		}
        return self::returnJson($data);
    }

	protected function onFind(){
        return $this->getFind();
    }

	/**
	 * 更新前操作
	 * @param array $data
	 * @return bool
	 * @author Colin <amcolin@126.com>
	 * @date 2022-02-08 下午10:05
	 */
    public function onUpdateBefore(&$data = []) {
		return parent::onUpdateBefore($data); // TODO: Change the autogenerated stub
	}

	/**
	 * 设置弹窗标题
	 * @return string
	 * @author Colin <amcolin@126.com>
	 * @date 2021-12-30 下午4:05
	 */
	protected static function setPageTitle() {
		return '新闻';
	}

	/**
	 * 设置面包屑
	 * @return array
	 * @author Colin <amcolin@126.com>
	 * @date 2021-12-30 下午4:05
	 */
	protected static function setCrumbs() {
		return ['投票管理' , '新闻管理'];
	}
}
